Optimize state merging process when there is no base state given #347
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, we were using
tfmerge
to merge the import state file and the base state file, by a per resource movement manner. This is fine in most cases. But there is still a space to improve the performance, when there is no base state given (i.e. not appending to an existing workspace). In this case, as long as the import items have no address conflicts (guaranteed byaztfy
), it can safely merge the state files by simply appending (resources
field). Also since this state file is a fresh new one, there is no special requirement on theserial
andlineage
.This PR also makes some other less related changes to make it more intuitive for library users:
NewMeta()
. The cache dir is only used to cache an auto-downloaded terraform binary. We now eliminate this behavior due to as a library, this method shall be thread-safe, and we try to avoid downloading behavior as possible. As a result,aztfy
now depends on a pre-installedterraform
executable that is located at $PATH. Hence mark this PR as a breaking-change.meta.Init()
, to make it match the tear-down operations inmeta.DeInit()
Config
now replaces.Append
by.OutputFileNames
to be more clear